package meituan;

import java.util.Scanner;

/**
 * @Author Stringzhua
 * @Date 2024/11/9 14:57
 * description:
 */
public class test03 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();


            int blueFormRed = a / x;
            int greenFromBlue = (b + blueFormRed) / y;

            int sets = Math.min(Math.min(a, b), greenFromBlue);
            System.out.println(sets);

        }
        sc.close();
    }
}
